<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <button onclick="myClick()">点击进行数据请求</button>
    <iframe src="http://localhost:8080/data.html" style="display: none;"  frameborder="0"></iframe>
    <script>
        window.addEventListener('message', function(data){
            alert(data.data)
        })
        function myClick() {
            document.querySelector('iframe').contentWindow.postMessage('','http://localhost:8080/data.html')
        }
    </script>
</body>

</html>
